$(function(){
	newborn_cont();
	increase_cont();
	disease_cont();
	symptom_cont();
	bloodDonation_cont();
	numberPeople_cont();
	settlementMethod_cont();
	personalStyle_cont();
	personalStyle2_cont();
	

function newborn_cont() {
	
let sta_newborn = echarts.init(document.querySelector('.newborn_cont'));
let option1 = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross',
            label: {
                backgroundColor: '#6a7985'
            }
        }
    },
    legend: {
        data: ['邮件营销']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '0%',
		top: '25%',
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            data: ['2013', '2014', '2015', '2016', '2017'],
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 }
        }
    ],
    yAxis: [
        {
            type: 'value',
			min: 0,
			max: 8000,
			interval: 2000,
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 },
			 splitLine:{
				 show:true,
				 lineStyle:{
					 type:'dashed',
					 color: '#10D1F4',
				 }
			 },
        }
		
    ],
    series: [
        {
            type: 'line',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            areaStyle: {
				color: '#9D3259'
			},
            data: [0, 8000, 6000, 8000, 7000],
			itemStyle : {
				normal : {
					lineStyle:{  
						color:'#A3345C'  
					}
				}
			},
			symbol: 'none',
        }
    ]
};
sta_newborn.setOption(option1);
window.addEventListener("resize",function(){
            sta_newborn.resize();
        });
}

function increase_cont() {
let sta_increase = echarts.init(document.querySelector('.increase_cont'));
let option2 = {
	    tooltip: {
	        trigger: 'axis'
	    },
	    grid: {
	        left: '3%',
	        right: '4%',
	        bottom: '-1%',
			top: '25%',
	        containLabel: true
	    },
	    xAxis: {
	        type: 'category',
	        boundaryGap: false,
	        data: ['2013', '2014', '2015', '2016', '2017'],
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 }
	    },
	    yAxis: {
	        type: 'value',
			splitLine:{
					 show:true,
					 lineStyle:{
						 type:'dashed'
					 }
				 },
				 min: -15,
				 max: 20,
				 interval: 5,
				 axisLabel:{
					 formatter:'{value} %'
				 },
				 axisLine: {
				 	lineStyle: {
				 		color:  '#00D1F7',
				 	}
				  },
			splitLine:{
				 show:true,
				 lineStyle:{
					 type:'dashed',
					 color: '#10D1F4',
				 }
			},
	    },
	    series: [
	        {
	            name: '出生率',
	            type: 'line',
	            data: [-10, -10, -10, -14, -10]
	        },
	        {
	            name: '死亡率',
	            type: 'line',
	            data: [-2, -2, -2, 0, 0]
	        },
	        {
	            name: '自然增长',
	            type: 'line',
	            data: [2, 2, 2, -10, 0]
	        }
	    ]
};
sta_increase.setOption(option2);
window.addEventListener("resize",function(){
            sta_increase.resize();
        });
}

function disease_cont() {
let sta_disease = echarts.init(document.querySelector('.disease_cont'));
let option3 = {
		dataset: {
			source: [
				['product', '2012', '2013', '2014', '2015', '2016', '2017'],
				['病人要求', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
				['屈光不正', 86.5, 92.1, 85.7, 83.1, 73.4, 55.1],
				['2型糖尿病', 24.1, 67.2, 79.5, 86.4, 65.2, 82.5],
				['上呼吸道感染', 55.2, 67.1, 69.2, 72.4, 53.9, 39.1]
			]
		},
		xAxis: {
			type: 'category',
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 }
			},
		yAxis: {
			gridIndex: 0,
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 },
			 splitLine:{
				 show:true,
				 lineStyle:{
					 type:'dashed',
					 color: '#10D1F4',
				 }
			 },
			},
		grid: {
			top: '55%',
			bottom: '9%',
			},
		series: [
			{type: 'line', smooth: true, seriesLayoutBy: 'row'},
			{type: 'line', smooth: true, seriesLayoutBy: 'row'},
			{type: 'line', smooth: true, seriesLayoutBy: 'row'},
			{type: 'line', smooth: true, seriesLayoutBy: 'row'},
			{
				type: 'pie',
				id: 'pie',
				radius: '30%',
				center: ['50%', '25%'],
				label: {
					formatter: '{b}: {@2012} ({d}%)'
				},
			}
		]
	};
sta_disease.setOption(option3);
window.addEventListener("resize",function(){
            sta_disease.resize();
        });
}

function symptom_cont() {
let sta_symptom = echarts.init(document.querySelector('.symptom_cont'));
let option4 = {
	title: {
		text: '住院症状',
		x: 'center',
		y: 'center',
		color: '#FFFFFF',
		textStyle: {
			color: '#FFF'
		}
	},
	 tooltip: {
	        trigger: 'item',
	        formatter: '{a} <br/>{b}: {c} ({d}%)'
	    },
	    legend: {
	        // orient: 'vertical',
	        left: 10,
			orient:'horizontal',
			type:'scroll',
			 textStyle:{
					color: '#FFFFFF'//字体颜色
						},
	        data: ['水痘', '支气管炎', '全身多处软组织挫伤', '右侧肺炎', '过敏性紫癜', '头面部皮肤挫伤', '右下肺炎']
	    },
		grid: {
			top: '3%',
			bottom: '9%',
			},
	    series: [
	        {
	            name: '访问来源',
	            type: 'pie',
	            radius: ['50%', '70%'],
	            avoidLabelOverlap: false,
	            label: {
	                show: false,
	                position: 'center'
	            },
	            emphasis: {
	                label: {
	                    show: true,
	                }
	            },
				center: ['50%', '55%'],
	            labelLine: {
	                show: true,
					 normal:{
					          length:5,  // 改变标示线的长度
					          lineStyle: {
					             color: "red"  // 改变标示线的颜色
					          }
					     },
	            },
				
				label: {
				     normal: {
				          textStyle: {
				                color: '#FFFFFF'  // 改变标示文字的颜色
				          }
				     }
				},
	            data: [
	                {value: 400, name: '水痘', itemStyle: {color: '#826AF9'}},
	                {value: 400, name: '支气管炎', itemStyle: {color: '#FFE700'}},
	                {value: 234, name: '全身多处软组织挫伤', itemStyle: {color: '#FF6C40'}},
	                {value: 234, name: '右侧肺炎', itemStyle: {color: '#2D99FF'}},
	                {value: 180, name: '过敏性紫癜', itemStyle: {color: '#ECCA19'}},
					{value: 160, name: '头面部皮肤挫伤', itemStyle: {color: '#38C88F'}},
					{value: 160, name: '右下肺炎', itemStyle: {color: '#1DB1D9'}}
	            ]
	        }
	    ]
}
sta_symptom.setOption(option4);
window.addEventListener("resize",function(){
            sta_symptom.resize();
        });
}

function bloodDonation_cont() {
let sta_bloodDonation = echarts.init(document.querySelector('.bloodDonation_cont'));
let option5 = {
	dataset: {
				source: [
					['product', '2012', '2013', '2014', '2015', '2016', '2017'],
					['A型 276', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
					['B型 78', 86.5, 92.1, 85.7, 83.1, 73.4, 55.1],
					['C型 78', 24.1, 67.2, 79.5, 86.4, 65.2, 82.5],
					['O型  196', 55.2, 67.1, 69.2, 72.4, 53.9, 39.1]
				]
			},
			xAxis: {
				type: 'category',
				axisLine: {
					lineStyle: {
						color:  '#00D1F7',
					}
				 }
				},
			yAxis: {
				gridIndex: 0,
				axisLine: {
					lineStyle: {
						color:  '#00D1F7',
					}
				 },
			 splitLine:{
				 show:true,
				 lineStyle:{
					 type:'dashed',
					 color: '#10D1F4',
				 }
			 },
				},
			grid: {
				top: '55%',
				bottom: '9%',
				},
			series: [
				{type: 'line', smooth: true, seriesLayoutBy: 'row'},
				{type: 'line', smooth: true, seriesLayoutBy: 'row'},
				{type: 'line', smooth: true, seriesLayoutBy: 'row'},
				{type: 'line', smooth: true, seriesLayoutBy: 'row'},
				{
					type: 'pie',
					id: 'pie',
					radius: '40%',
					center: ['50%', '25%'],
					label: {
						formatter: '{b}: {@2012} ({d}%)'
					},
				}
			]
}
sta_bloodDonation.setOption(option5);
window.addEventListener("resize",function(){
            sta_bloodDonation.resize();
        });
}

function numberPeople_cont() {
let sta_numberPeople = echarts.init(document.querySelector('.numberPeople_cont'));
let option6 = {
	tooltip: {
		trigger: 'axis',
		axisPointer: {
			type: 'shadow'
		},
		formatter: function (params) {
			var tar = params[1];
			return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
		}
	},
	grid: {
		left: '3%',
		right: '4%',
		bottom: '3%',
		top: '20%',
		containLabel: true
	},
	xAxis: {
		type: 'category',
		splitLine: {show: false},
		data: ['总数', '桓台中学', '燕山中学', '文化小学', '外国语小学', '其他'],
		axisLine: {
			lineStyle: {
				color:  '#00D1F7',
			}
		 }
	},
	yAxis: {
		type: 'value',
		min: 0,
		max: 2000,
		interval: 300,
		axisLine: {
			lineStyle: {
				color:  '#00D1F7',
			}
		 },
		 splitLine:{
			 show:true,
			 lineStyle:{
				 type:'dashed',
				 color: '#10D1F4',
			 }
		 },
	},
	series: [
		{
			name: '辅助',
			type: 'bar',
			stack: '总量',
			barWidth : 40,
			itemStyle: {
				barBorderColor: 'rgba(0,0,0,0)',
				color: 'rgba(0,0,0,0)'
			},
			data: [0, 0, 10, 20, 40, 400]
		},
		{
			name: '生活费',
			type: 'bar',
			stack: '总量',
			itemStyle: {
				barBorderColor: '#D63131',
				color: '#D63131'
			},
			label: {
				show: true,
				position: 'inside'
			},
			data: [1756, 62, 62, 71, 65, 1460]
		}
	]
}
sta_numberPeople.setOption(option6);
window.addEventListener("resize",function(){
            sta_numberPeople.resize();
        });
}

function settlementMethod_cont() {
let sta_settlementMethod = echarts.init(document.querySelector('.settlementMethod_cont'));
let option7 = {
	 tooltip: {
			trigger: 'item',
			formatter: '{a} <br/>{b}: {c} ({d}%)'
		},
		legend: {
			textStyle:{
				color: '#FFFFFF'
					},
			x: '100px',
			y: 'bottom',
			orient:'horizontal',
			left: 10,
			data: ['自费', '医保', '农保']
		},
		series: [
			{
				name: '访问来源',
				type: 'pie',
				radius: ['40%', '60%'],
				avoidLabelOverlap: false,
				label: {
					show: false,
					position: 'center'
				},
				center: ['50%', '55%'],
				emphasis: {
					label: {
						show: true,
						fontSize: '30',
						fontWeight: 'bold'
					}
				},
				labelLine: {
					show: false
				},
				data: [
					{value: 335, name: '自费'},
					{value: 335, name: '医保'},
					{value: 335, name: '农保'},
				]
			}
		]
}
sta_settlementMethod.setOption(option7);
window.addEventListener("resize",function(){
            sta_settlementMethod.resize();
        });
}

function personalStyle_cont() {
let sta_personalStyle = echarts.init(document.querySelector('.personalStyle_cont'));
let option8 = {
	    tooltip: {
	        trigger: 'axis',
	        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
	            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
	        },
	        formatter: function (params) {
	            var tar = params[1];
	            return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
	        }
	    },
	    grid: {
	        left: '10%',
	        right: '4%',
	        bottom: '15%',
	        containLabel: false,
			top: '25%'
	    },
	    xAxis: {
	        type: 'category',
	        splitLine: {show: false},
	        data: ['2013', '2014', '2015', '2016', '2017'],
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 },
	    },
	    yAxis: {
	        type: 'value',
			splitNumber:5,
			min: 0,
			max: 400,
			interval: 100,
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 },
			 splitLine:{
				 show:true,
				 lineStyle:{
					 type:'dashed',
					 color: '#10D1F4',
				 }
			 },
	    },
	    series: [
	        {
	            name: '辅助',
	            type: 'bar',
	            stack: '总量',
	            itemStyle: {
	                barBorderColor: '#2997FF',
	                color: '#2997FF'
	            },
				barWidth : 30,
	            data: [150, 90, 220, 150, 150]
	        },
	        {
	            name: '生活费',
	            type: 'bar',
	            stack: '总量',
	            label: {
	                show: true,
	                position: 'inside'
	            },
				itemStyle: {
				    barBorderColor: '#FF9F31',
				    color: '#FF9F31'
				},
	            data: [150, 220, 70, 220, 90],
				label: {
				show: false,
						},
	        }
	    ]
}
sta_personalStyle.setOption(option8);
window.addEventListener("resize",function(){
            sta_personalStyle.resize();
        });
}

function personalStyle2_cont() {
let sta_personalStyle2 = echarts.init(document.querySelector('.personalStyle2_cont'));
let option9 = {
		legend: {
			data: ['中医院', '人民医院', '乡镇卫生院'],
			textStyle:{
				color: '#FFFFFF'
					},
		},
		grid: {
			left: '3%',
			right: '4%',
			bottom: '3%',
			containLabel: true
		},
		xAxis: {
			type: 'category',
			boundaryGap: false,
			data: ['08-01', '08-02', '08-03', '08-04', '08-05', '08-06', '08-07'],
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				},
				interval: 0
			 },
		},
		yAxis: {
			type: 'value',
			axisLine: {
				lineStyle: {
					color:  '#00D1F7',
				}
			 },
			 splitLine:{
				 show:true,
				 lineStyle:{
					 type:'dashed',
					 color: '#10D1F4',
				 }
			 },
		},
		series: [
			{
				name: '中医院',
				type: 'line',
				stack: '总量',
				data: [120, 132, 101, 134, 90, 230, 210]
			},
			{
				name: '人民医院',
				type: 'line',
				stack: '总量',
				data: [220, 182, 191, 234, 290, 330, 310]
			},
			{
				name: '乡镇卫生院',
				type: 'line',
				stack: '总量',
				data: [150, 232, 201, 154, 190, 330, 410]
			},
		]
}
sta_personalStyle2.setOption(option9);
window.addEventListener("resize",function(){
            sta_personalStyle2.resize();
        });
}
})
function currentTime(){
	let date = new Date();
	
	let hous = date.getHours() > 10 ? date.getHours() : "0" + date.getHours();
	let moun = date.getMinutes() > 10 ? date.getMinutes() : "0" + date.getMinutes();
	let sec = date.getSeconds() > 10 ? date.getSeconds() : "0" + date.getSeconds();
	
	return hous + ':' + moun + ':' + sec;
}
setInterval(function(){
	$('.time').text(currentTime())
},1000)

function currentWeek(){
	let date = new Date();
	let week = date.getDay();
	
	switch(week){
		case 0:
			return '星期日';
			break;
		case 1:
			return '星期一';
			break;
		case 2:
			return '星期二';
			break;
		case 3:
			return '星期三';
			break;
		case 4:
			return '星期四';
			break;
		case 5:
			return '星期五';
			break;
		case 6:
			return '星期六';
			break;
	}
}

setInterval(function(){
	$('.week').text(currentWeek());
},1000)

function currentDate(){
	let date = new Date();
	let year = date.getFullYear();
	let mon = (date.getMonth() + 1) > 10 ? date.getMonth() + 1 : "0" + (date.getMonth() + 1);
	let date1 = date.getDate() > 10 ? date.getDate() : "0" + date.getDate();
	
	return year + '.' + mon + '.' + date1;
}

setInterval(function(){
	$('.year').text(currentDate());
})